<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in">
      <div class="cornerComment-in-title">
        <span>考勤管理表格总览</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <el-table
            ref="multipleTable"
            :data="arryList"
            :stripe="tableoption.tableStripe"
            :border="tableoption.tableBorder"
            tooltip-effect="dark"
            style="width: 100%"
            header-cell-class-name="table-text-c"
            cell-class-name="table-text-c">
          <el-table-column
              prop="name"
              label="表格名称"
              width="230">
          </el-table-column>
          <el-table-column
              prop="name"
              label="筛选条件">
            <template slot-scope="scope">
              <el-date-picker
                  v-model="scope.row.query.start_time"
                  v-if="scope.row.needQuery.indexOf('day')!==-1"
                  type="date"
                  placeholder="选择日期"
                  value-format="yyyy-MM-dd"
                  size="small"
                  class="w-140"
                  :picker-options="pickerOptions1"
              ></el-date-picker>
              <el-date-picker
                  v-model="scope.row.query.month"
                  v-if="scope.row.needQuery.indexOf('month')!==-1"
                  size="small"
                  type="month"
                  format="yyyyMM"
                  value-format="yyyyMM"
                  placeholder="选择月份">
              </el-date-picker>
              <el-select v-if="scope.row.needQuery.indexOf('semester')!==-1" placeholder="学年" v-model="scope.row.query.semester_id" size="small"
                         class="w-200 mr-10" @change="getChangeOption(scope.$index)">
                <el-option :label="item.year" :value="item.id" v-for="(item, index) in yearList"
                           :key="index"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column
              label="操作"
              width="150"
              align="center">
            <template slot-scope="scope">
              <!--                  disabledState queryOption-->
              <excelDownLoadBtn :disabledState="disabledState
              (scope.row)" :downloadOption="scope.row"></excelDownLoadBtn>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click.native="closePOpup" size="small">返回</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import {tableoption} from '@/utils/util.js'
import dataDownLine from "./dataDownLine";
export default {
  props: ['visible'],
  components: {},
  data() {
    return {
      dialogVisible: false,
      arryList: JSON.parse(JSON.stringify(dataDownLine.data)),
      tableoption: tableoption,
      pickerOptions1: {
        disabledDate(time) {
          return time.getTime() > Date.now() //  - 8.64e7
        }
      },
      yearList: []
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if(this.visible){
        this.arryList = JSON.parse(JSON.stringify(dataDownLine.data))
        this.getYearList()
      }else{
        this.yearList = []
      }
    }
  },
  created() {

  },
  methods: {
    checkEditFn() {
      if (!this.infoForm[this.itemlable]) {
        this.$message.error('请填写信息');
        return
      }
      this.$emit('checkList', {name: this.itemlable, val: this.infoForm[this.itemlable]})
      this.closePOpup()
    },
    // 获取学期
    getYearList(){
      this.$fetch(this.api.setting.semesterIndex, {}).then((response) => {
        for (let i in response.list) {
          if (response.list[i].type === 1) {
            response.list[i].year = response.list[i].year + ' 下学期'
          } else {
            response.list[i].year = response.list[i].year + ' 上学期'
          }
        }
        this.yearList = response.list
      }).catch((err) => {
        console.log(err)
      })
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    disabledState(row){
      let state = false
      for(let item of row.disabled){
        if(!row.query[item]){
          state = true
        }
      }
      return state
    },
    getChangeOption(index){
      for(let item of this.yearList){
        if(item.id===this.arryList[index].query.semester_id){
          this.arryList[index].semesterName = item.year
        }
      }
    }
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 80%;
  height: 70%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.resruitment-title {
  padding: 5px 0;
  border-bottom: 2px solid #abd3f3;
  margin-bottom: 20px;
}

.el-radio {
  margin-right: 20px;
}

.jobTime {
  display: flex;
  align-items: center;
}

.jobTime span {
  padding: 0 10px;
}
</style>


